package com.kapcb.common.result;

import java.util.ArrayList;
import java.util.List;

/**
 * <a>Title: BaseTree </a>
 * <a>Author: Kapcb <a>
 * <a>Description: BaseTree <a>
 *
 * @author Kapcb
 * @version 1.0
 * @date 2024/4/21 11:17
 * @since 1.0
 */
public class BaseTree<T> implements Tree<Long, T> {

    /**
     * node id
     */
    private Long id;

    /**
     * parent node id, if parentId's value is 0 the node must be parent node
     */
    private Long parentId;

    /**
     * children node
     */
    private List<T> children = new ArrayList<>();

    public BaseTree() {
    }

    public BaseTree(Long id, Long parentId) {
        this.id = id;
        this.parentId = parentId;
    }

    public BaseTree(Long id, Long parentId, List<T> children) {
        this.id = id;
        this.parentId = parentId;
        this.children = children;
    }

    @Override
    public Long id() {
        return this.id;
    }

    @Override
    public Long parentId() {
        return this.parentId;
    }

    @Override
    public List<T> children() {
        return this.children;
    }
}
